﻿using rmTest.Common;
using rmTest_2.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace rmTest_2
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                ShowVocal<EastVocalMimicry>();
                ShowVocal<SouthVocalMimicry>();
                ShowVocal<WestVocalMimicry>();
                ShowVocal<NorthVocalMimicry>();
            }
            catch (Exception ex)
            {
                LogUtil.Instance.PrintLog(ex.Message);
            }
            Console.ReadKey();
        }

        private static void ShowVocal<T>() where T : BaseVocalMimicry, IPay
        {
            T t = Activator.CreateInstance(typeof(T)) as T;
            var fields = t.GetType().GetFields();
            foreach (var item in fields)
            {
                LogUtil.Instance.PrintLog("Name:" + item.Name + ";value:" + item.GetValue(t));
            }
            var props = t.GetType().GetProperties();
            foreach (var item in props)
            {
                LogUtil.Instance.PrintLog("Name:" + item.Name + ";value:" + item.GetValue(t));
            }
            t.activeDelegate += new Action(() => t.Start());
            t.activeDelegate += new Action(() => t.ShowStart());
            t.activeDelegate += new Action(() => t.ImitateDogVoice());
            t.activeDelegate += new Action(() => t.ImitatePeopleVoice());
            t.activeDelegate += new Action(() => t.ImitateWindVoice());
            Action<string> action = x => LogUtil.Instance.PrintLog(t.Name + "：表演绝活"); ;
            t.activeDelegate += new Action(() => t.UniqueSkill(action));
            t.activeDelegate += new Action(() => t.ShowEnd());
            t.activeDelegate += new Action(() => t.PayMoney());

            t.activeDelegate.Invoke();
        }
    }
}
